import Vue from "vue";
import Main from '../Views/admin/index.vue'
import Home from '../Views/Home.vue'
import Login from '../Views/Login.vue'
import VueRouter from "vue-router";
Vue.use(VueRouter)
const routes = [{
    path: '/',
    name: 'Main',
    component: Main,
    redirect: 'login', // 重定向
    children: [
        // 子路由
        {
            path: '/home',
            name: 'home',
            component: Home,
        }, // 首页
        {
            path: '/info',
            name: 'info',
            component: () => import('@/Views/Info.vue'),
        },
        {
            path: '/owner',
            name: 'owner',
            component: () => import('@/Views/admin/Owner/index.vue'),
        },
        {
            path: '/worker',
            name: 'worker',
            component: () => import('@/Views/admin/Worker/index.vue'),
        },
        {
            path: '/complain',
            name: 'complain',
            component: () => import('@/Views/admin/Complain/index.vue'),
        },
        {
            path: '/lose',
            name: 'lose',
            component: () => import('@/Views/admin/Lose/index.vue'),
        },
        {
            path: '/money',
            name: 'money',
            component: () => import('@/Views/admin/Money/index.vue'),
        },
        {
            path: '/notice',
            name: 'notice',
            component: () => import('@/Views/admin/Notice/index.vue'),
        },
        {
            path: '/schedule',
            name: 'schedule',
            component: () => import('@/Views/admin/Schedule/index.vue'),
        },
        {
            path: '/repair',
            name: 'repair',
            component: () => import('@/Views/admin/Repair/index.vue'),
        },
    ]
},
{
    path: '/login', // 登录
    name: 'login',
    component: Login
},
]

const router = new VueRouter({
    routes
})

// router.beforeEach((to, from, next) => {
//     const { permission } = JSON.parse(window.localStorage.getItem('userInfo'))
//     if(!permission) {
//         next('/home')
//     } else {
//         next()
//     }
// })

export default router